package com.tjetc.utils;

import cn.hutool.core.collection.CollUtil;
import lombok.Data;

import java.util.List;

@Data
public class MultiDelayMessage<T> {

    //消息体
    private T data;

    //记录延迟时间的集合
    private List<Long> delayMills;

    public MultiDelayMessage(T data, List<Long> delayMills) {
        this.data = data;
        this.delayMills = delayMills;
    }


    public static <T> MultiDelayMessage<T> of(T data, Long ... delayMills) {
        return new MultiDelayMessage<>(data, CollUtil.newArrayList(delayMills));
    }

    //获取并移除下一个延迟消息
    //Return 队列的第一个延迟消息
    public Long removeNextDelay(){
        return delayMills.remove(0);
    }

    //是否还有下一个延迟时间
    public boolean hasNextDelay(){
        return !delayMills.isEmpty();
    }




}
